{include file="Public:header2"/}
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <form method="get" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">                
                <div class="layui-inline">
                    <div class="layui-input-inline" style="width: 300px;margin-left: 0px">
                        <input type="text" name="title" value="{$Request.get.title}" placeholder="请输入盒子标题" autocomplete="off" class="layui-input">
                    </div>
                </div>   
                <div class="layui-inline">
                    <div class="layui-input-inline" style="width: 180px;margin-left: 0px">
                        <select name="status" style="width:100%">
                            <option value="">--请选择状态--</option>
                            <option value="1" {if condition="$Request.get.status eq 1"}selected{/if}>商家</option>
                            <option value="2" {if condition="$Request.get.status eq 2"}selected{/if}>下架</option>
                            <option value="3" {if condition="$Request.get.status eq 3"}selected{/if}>售罄</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline" style="width: 180px;margin-left: 0px">
                        <select name="type" style="width:100%">
                            <option value="">--盒子类型--</option>
                            <option value="1" {if condition="$Request.get.type eq 1"}selected{/if}>一番赏</option>
                            <option value="2" {if condition="$Request.get.type eq 2"}selected{/if}>无限赏</option>
                            <option value="3" {if condition="$Request.get.type eq 3"}selected{/if}>擂台赏</option>
                            <option value="5" {if condition="$Request.get.type eq 5"}selected{/if}>积分赏</option>
                            <option value="6" {if condition="$Request.get.type eq 6"}selected{/if}>全局赏</option>
                            <option value="8" {if condition="$Request.get.type eq 8"}selected{/if}>领主赏</option>
                            <option value="9" {if condition="$Request.get.type eq 9"}selected{/if}>连击赏</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin mmm" lay-submit lay-filter="LAY-user-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </form>

        <div class="layui-card-body">
            <xblock>
                <div style="padding-bottom: 10px;">
                    <a class="layui-btn" onclick="goods_add()">添加盒子</a>
                    <span style="line-height:40px;float:right;">共有数据： {$count}条</span>
                </div>
            </xblock>
            <table class="layui-table">
                <thead>
                <tr>
                    <th>盒子ID</th>
                    <th>盒子类型</th>
                    <th>盒子名称</th>
                    <th>盒子价格</th>
                    <th>盒子图片</th>
                    <th>盒子详情图片</th>
                    <th>盒子套数</th>
                    <th>锁箱模式</th>
<!--                    <th>发券开关</th>-->
<!--                    <th>发积分开关</th>-->
                    <th>首页显示</th>
                    <th>
                        擂台赏<br>抽全局赏数量
                    </th>
                    <th>排序</th>
                    <th>状态</th>
                    <th>添加时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="list" id="vo"}
                    <tr>
                        <td>{$vo['id']}</td>
                        <td>
                            {if condition="$vo['type'] eq 1"}
                            <button class="layui-btn layui-btn-normal layui-btn-radius layui-btn-sm">一番赏</button>
                            {elseif condition="$vo['type'] eq 2"}
                            <button class="layui-btn layui-btn-normal layui-btn-radius layui-btn-sm">无限赏</button>
                            {elseif condition="$vo['type'] eq 3"}
                            <button class="layui-btn layui-btn-normal layui-btn-radius layui-btn-sm">擂台赏</button>
                            {elseif condition="$vo['type'] eq 5"}
                            <button class="layui-btn layui-btn-normal layui-btn-radius layui-btn-sm">积分赏</button>
                            {elseif condition="$vo['type'] eq 6"}
                            <button class="layui-btn layui-btn-normal layui-btn-radius layui-btn-sm">全局赏</button>
                            {elseif condition="$vo['type'] eq 8"}
                            <button class="layui-btn layui-btn-normal layui-btn-radius layui-btn-sm">领主赏</button>
                            {elseif condition="$vo['type'] eq 9"}
                            <button class="layui-btn layui-btn-normal layui-btn-radius layui-btn-sm">连击赏</button>
                            {/if}
                        </td>
                        <td>{$vo['title']}</td>
                        <td>{$vo['price']}</td>
                        <td><img src="{PHP} echo imageUrl($vo['imgurl']){/php}" style="width:60px;height:60px;"></td>
                        <td>{if $vo['imgurl_detail']}<img src="{PHP} echo imageUrl($vo['imgurl_detail']){/php}" style="width:60px;height:60px;">{/if}</td>
                        <td>{if $vo['stock'] gt 0}{$vo['stock']}{/if}</td>
                        <td>
                            {if condition="$vo['lock_is'] eq 1"}
                            <button class="layui-btn layui-btn-warm layui-btn-sm">状态：开启</button>
                            <br>
                            <button class="layui-btn layui-btn-warm layui-btn-sm">时间：{$vo['lock_time']}秒</button>
                            {/if}
                        </td>
<!--                        <td>-->
<!--                            {if $vo['coupon_is'] eq 1}-->
<!--                            <button class="layui-btn layui-btn-warm layui-btn-sm">状态：开启</button>-->
<!--                            <br>-->
<!--                            <button class="layui-btn layui-btn-warm layui-btn-sm">概率：{$vo['coupon_pro']*1}%</button>-->
<!--                            {/if}-->
<!--                        </td>-->
<!--                        <td>-->
<!--                            {if $vo['integral_is'] eq 1}-->
<!--                            <button class="layui-btn layui-btn-warm layui-btn-radius layui-btn-sm">开启</button>-->
<!--                            {/if}-->
<!--                        </td>-->
                        <td>
                            {if $vo['show_is'] eq 1}
                            <button class="layui-btn layui-btn-danger layui-btn-radius layui-btn-sm">否</button>
                            {/if}
                        </td>
                        <td>{if $vo['prize_num'] gt 0}{$vo['prize_num']}{/if}</td>
                        <td>{$vo['sort']}</td>
                        <td>
                            {if $vo['status'] eq 1}
                                 <button onClick="del({$vo.id},2,'下架')" class="layui-btn layui-btn-danger layui-btn-xs"><i class="layui-icon">&#xe61a;</i>下架</button>
<!--                                <button class="layui-btn layui-btn-sucess layui-btn-radius layui-btn-sm">上架</button>-->
                            {elseif  $vo['status'] eq 2}
                                 <button onClick="del({$vo.id},1,'上架')" class="layui-btn layui-btn-info layui-btn-xs"><i class="layui-icon">&#xe619;</i>上架</button>
<!--                                <button class="layui-btn layui-btn-danger layui-btn-radius layui-btn-sm">下架</button>-->
                            {elseif  $vo['status'] eq 3}
                                <button class="layui-btn layui-btn-disabled layui-btn-radius layui-btn-sm">售罄</button>
                            {/if}
                        </td>
                        <td>{$vo['addtime']|date="Y-m-d H:i"}</td>
                        <td>
                            <a style="text-decoration:none" title="编辑" onclick="goods_edit({$vo.id})"  class="layui-btn layui-btn-normal layui-btn-xs">
                                <i class="layui-icon layui-icon-edit"></i>编辑
                            </a>
                            <div style="margin-top: 8px"></div>
                            <a style="text-decoration:none" onclick="goodslist({$vo['id']},'{$vo.title}')"  class="layui-btn layui-btn-warm layui-btn-xs "><i class="layui-icon layui-icon-cart-simple"></i>奖品</a>
                            <div style="margin-top: 8px"></div>
<!--                            {if condition="$vo['status'] eq 1"}-->
<!--                                <button onClick="del({$vo.id},2,'下架')" class="layui-btn layui-btn-danger layui-btn-xs"><i class="layui-icon">&#xe61a;</i>下架</button>-->
<!--                            {else /}-->

<!--                            {/if}-->
                            <div style="margin-top: 8px"></div>
                            <a style="text-decoration:none" onClick="del({$vo.id},3,'删除')" class="layui-btn layui-btn-danger layui-btn-xs">
                                <i class="layui-icon layui-icon-delete"></i>删除
                            </a>
                            
                            <a style="text-decoration:none" onClick="del({$vo.id},4,'复制')" class="layui-btn layui-btn-normal layui-btn-xs">
                                <i class="layui-icon layui-icon-edit"></i>复制
                            </a>
                        </td>
                    </tr>
                {/volist}

                {if condition="empty($list)"}
                    <tr><td colspan='11' style="text-align:center;">暂时没有数据！</td></tr>
                {/if}
               
                </tbody>
            </table>
            <div class="layui-box layui-laypage layui-laypage-default">
                {$page|raw}
            </div>
        </div>
    </div>
</div>
{include file="Public:footer"/}
<script type="text/javascript">
    layui.use(['layer','table'], function(){
        var $ = layui.$;

        
    })

    //添加盒子
    function goods_add() {
        var url  = "{:url('/admin/goods_add')}";
        layer.open({
            type: 2,
            title: '添加盒子',
            shadeClose: false,
            shade: 0.3,
            area: ['90%', '90%'],
            content: url,
        });
    }

    //编辑盒子
    function goods_edit(id) {
        var url  = "{:url('/admin/goods_edit?id="+id+"')}";
        layer.open({
            type: 2,
            title: '编辑盒子',
            shadeClose: false,
            shade: 0.3,
            area: ['90%', '90%'],
            content: url,
        });
    }

    //盒子奖品
    function goodslist(goods_id,title) {
        var url  = "{:url('/admin/goodslist?goods_id="+goods_id+"')}";
        layer.open({
            type: 2,
            title: title+'  盒子奖品',
            shadeClose: false,
            shade: 0.3,
            area: ['95%', '95%'],
            content: url,
        });
    }

    //上下架
    function del(id,type,type_name){
        layer.confirm('确认要执行'+type_name+'操作吗？',function(){
            var url = "{:url('/admin/goods_del')}";
            var load=layer.load(2);
            var $ = layui.$;
            $.post(url,{"id":id,'type':type},function(data){
                if(data.status == 1){
                    layer.msg('操作成功',{icon:1,time:1000},function(){
                        location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon:2,anim:6,time:1000},function(){
                        layer.close(load);
                    });
                }
            })
        });
    }
</script>
</body>
</html>


